<%--
  Created by IntelliJ IDEA.
  User: 娜娜
  Date: 2024/12/23
  Time: 21:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.milk.entity.MilkTeaDrinks" %>
<html>
<head>
    <title>饮品管理</title>
</head>
<body>
<h2>饮品管理</h2>
<a href="<%=request.getContextPath()%>/drinks/add">添加饮品</a>
<form action="<%=request.getContextPath()%>/drinks/search" method="get">
    <label for="searchName">搜索饮品：</label><input type="text" id="searchName" name="searchName"><br>
    <input type="submit" value="搜索">
</form>
<table border="1">
    <tr>
        <th>ID</th>
        <th>名称</th>
        <th>分类</th>
        <th>价格</th>
        <th>描述</th>
        <th>操作</th>
    </tr>
    <%
        List<MilkTeaDrinks> drinks = (List<MilkTeaDrinks>) request.getAttribute("drinks");
        if (drinks != null) {
            for (MilkTeaDrinks drink : drinks) {
    %>
    <tr>
        <td><%=drink.getId()%></td>
        <td><%=drink.getName()%></td>
        <td><%=drink.getCategory()%></td>
        <td><%=drink.getPrice()%></td>
        <td><%=drink.getDescription()%></td>
        <td>
            <a href="<%=request.getContextPath()%>/drinks/edit?id=<%=drink.getId()%>">编辑</a>
            <a href="<%=request.getContextPath()%>/drinks/delete?id=<%=drink.getId()%>">删除</a>
        </td>
    </tr>
    <%
            }
        }
    %>
</table>
</body>
</html>